package 双指针.删除有序数组中的重复项26;

import utils.Utils;

public class Solution {

    public static int removeDuplicates(int[] nums) {
        if(nums == null || nums.length < 1){
            return 0;
        }
        int count = 1;
        for(int i=1,j=1;j<nums.length;j++){
            if(nums[j] - nums[j-1] != 0){
                nums[i] = nums[j];
                i++;
                count++;
            }
        }
        return count;
    }
    public static void main(String[] args) {
        //int[] nums = {0,0,1,1,1,2,2,3,3,4};
        //int[] nums = {0,1,2,3,4};
        //int[] nums = {0};
        int[] nums = {};
        Utils.printInt(removeDuplicates(nums));
    }
}
